﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Linq.Expressions;
//using NLite.Messaging;
//using NLite.Domain;
//using NLite.Infrastructure;

//namespace NLite.Domain
//{

//    /// <summary>
//    /// 
//    /// </summary>
//    [Component(Lifestyle= LifestyleFlags.Transient)]
//    public abstract class DomainService
//    {
//        /// <summary>
//        /// 服务请求对象
//        /// </summary>
//        public IServiceRequest Request { get; set; }
//        /// <summary>
//        /// 响应对象
//        /// </summary>
//        public IServiceResponse Response { get; set; }

//        protected IDictionary<string, object> Context
//        {
//            get
//            {
//                return  Request.Context;
//            }
//        }
       
//        /// <summary>
//        /// Error 状态
//        /// </summary>
//        protected IErrorState ErrorState { get; private set; }
//        /// <summary>
//        /// 操作元数据
//        /// </summary>
//        protected OperationDescriptor OperationDescriptor { get; private set; }


//        internal void OnOperationExecuted(IOperationExecutedContext ctx)
//        {
//            OnExecuted();
//            Request = null;
//            Response = null;
//            ErrorState = null;
          
//            OperationDescriptor = null;
//        }

//        protected virtual void OnExecuted()
//        {
//        }

//        internal void OnOperationExecuting(IOperationExecutingContext ctx)
//        {
//            Request = ctx.Request;
//            Response = ctx.Response;
//            ErrorState = Response.ErrorState;
          
//            OperationDescriptor = ctx.OperationDescriptor;
//            ctx.Cancelled =! OnExecuting();
//        }

//        protected virtual bool OnExecuting()
//        {
//            return true;
//        }
//    }

//    /// <summary>
//    /// Provides methods that respond to mvc controller requests .
//    /// </summary>
//    public abstract class DomainService2 : DomainService
//    {
//        /// <summary>
//        /// 临时对象
//        /// </summary>
//        protected IDictionary<string, object> TempData
//        {
//            get
//            {
//                if (!Context.ContainsKey("TempData"))
//                    Context["TempData"] = new DictionaryWrapper();
//                return Context["TempData"] as IDictionary<string, object>;
//            }
//        }
//        /// <summary>
//        /// 临时对象
//        /// </summary>
//        protected IDictionary<string, object> ViewData
//        {
//            get
//            {
//                if (!Context.ContainsKey("ViewData"))
//                    Context["ViewData"] = new DictionaryWrapper();
//                return Context["ViewData"] as IDictionary<string, object>;
//            }
//        }

//    }
//}
